﻿<Window x:Class="CloudStorageLight.WpfClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:properties="clr-namespace:CloudStorageLight.WpfClient.Properties"
        xmlns:local="clr-namespace:CloudStorageLight.WpfClient"
        xmlns:vg="clr-namespace:ViewMaker.Core.Wpf;assembly=ViewMaker.Core" 
        Title="{Binding Path=Title}" Height="600" Width="800" Loaded="Window_Loaded" Unloaded="Window_Unloaded" Icon="Images/cloudstoragelightlog32.bmp">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <local:PercentageConverter x:Key="PercentageConverter"/>
        <local:BindingProxy x:Key="proxy" Data="{Binding}" />
        <Style TargetType="ListViewItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        </Style>
        <Style TargetType="{x:Type Control}" x:Key="baseStyle">
            <Setter Property="FontSize" Value="{Binding Path=Data.FontSize, Source={StaticResource proxy}}" />
        </Style>
        <Style TargetType="TextBlock">
            <Setter Property="FontSize" Value="{Binding Path=Data.FontSize, Source={StaticResource proxy}}" />
        </Style>
        <Style TargetType="local:AppListView">
            <Setter Property="FontSize" Value="{Binding Path=Data.FontSize, Source={StaticResource proxy}}" />
        </Style>

        <Style TargetType="{x:Type Button}" BasedOn="{StaticResource baseStyle}"></Style>
        <Style TargetType="{x:Type Label}" BasedOn="{StaticResource baseStyle}"></Style>
        <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource baseStyle}"></Style>
        <Style TargetType="{x:Type ListView}" BasedOn="{StaticResource baseStyle}"></Style>
        <Style TargetType="{x:Type TreeView}" BasedOn="{StaticResource baseStyle}"></Style>
        <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource baseStyle}"></Style>
        <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource baseStyle}"></Style>
        <!-- ComboBox, RadioButton, CheckBox, etc... -->

    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="20"/>
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Name="FileMenu" Header="{x:Static properties:Resources.MsgFile}">
                <MenuItem Header="{x:Static properties:Resources.MsgOpen}" Name="OpenCommand" Click="OpenCommand_Click" />
                <Separator/>
                <MenuItem Header="{x:Static properties:Resources.MsgRecentFile}" ItemsSource="{Binding RecentFiles}" >
                    <MenuItem.ItemContainerStyle>
                        <Style>
                            <Setter Property="MenuItem.Header" Value="{Binding Path}"/>
                            <EventSetter Event="MenuItem.Click"  Handler="RecentFiles_Click" />
                        </Style>
                    </MenuItem.ItemContainerStyle>
                </MenuItem>
                <MenuItem Header="{x:Static properties:Resources.MsgEditingFiles}" ItemsSource="{Binding EditingFiles}" >
                    <MenuItem.Resources>
                        <ContextMenu x:Key="editingMenu" >
                            <MenuItem Header="{x:Static properties:Resources.MsgOpenFolder}" Click="MenuItem_Open"  />
                            <MenuItem Header="{x:Static properties:Resources.MsgCheckin}" Click="MenuItem_Checkin"  />
                            <MenuItem Header="{x:Static properties:Resources.MsgCancelCheckout}" Click="MenuItem_CancelCheckout" />
                        </ContextMenu>
                    </MenuItem.Resources>
                    <MenuItem.ItemContainerStyle>
                        <Style>
                            <Setter Property="MenuItem.Header" Value="{Binding Path}"/>
                            <Setter Property="MenuItem.ContextMenu" Value="{StaticResource editingMenu}" />
                            <EventSetter Event="MenuItem.Click"  Handler="RecentFiles_Click" />
                        </Style>
                    </MenuItem.ItemContainerStyle>
                </MenuItem>
                <MenuItem Header="{x:Static properties:Resources.MsgFavorites}" ItemsSource="{Binding FavoriteList}" >
                    <MenuItem.Resources>
                        <ContextMenu x:Key="favoriteMenu" >
                            <MenuItem Header="{x:Static properties:Resources.MsgRemoveFavorite}" Click="MenuItem_RemoveFavorite"  />
                        </ContextMenu>
                    </MenuItem.Resources>
                    <MenuItem.ItemContainerStyle>
                        <Style>
                            <Setter Property="MenuItem.ContextMenu" Value="{StaticResource favoriteMenu}" />
                            <EventSetter Event="MenuItem.Click"  Handler="FavoriteList_Click" />
                        </Style>
                    </MenuItem.ItemContainerStyle>
                </MenuItem>
                <Separator/>
                <!--<MenuItem Header="Load test" Name="LoadTestCommand" Command="{Binding LoadTestCommand}" />-->
                <MenuItem Header="{x:Static properties:Resources.MsgExit}" Name="ExitCommand" Click="ExitCommand_Click" />
            </MenuItem>
            <MenuItem Header="{x:Static properties:Resources.MsgFormat}">
                <MenuItem Header="{x:Static properties:Resources.MsgFont}"  ItemsSource="{Binding FontSizes}">
                    <MenuItem.ItemContainerStyle>
                        <Style>
                            <Setter Property="MenuItem.Header" Value="{Binding}"/>
                            <EventSetter Event="MenuItem.Click"  Handler="FontSizes_Click" />
                        </Style>
                    </MenuItem.ItemContainerStyle>
                </MenuItem>
            </MenuItem>
        </Menu>
        <ContentControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib" IsTabStop="False" Grid.Row="1">
            <ContentControl.Resources>
                <ResourceDictionary>
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="/ViewMaker.Core;component/wpf/wpfgenericresource.xaml" />
                        <ResourceDictionary Source="/ViewMaker.Core;component/wpf/wpferrorstyleresource.xaml" />
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </ContentControl.Resources>
            <Grid Name="MainVM" DataContext="{Binding Mode=OneWay}" IsEnabled="{Binding Path=IsEnabled}" >
                
                <Grid Name="MainVMDataPanel" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
                    <!--<Button Name="GetRecentCommand" Command="{Binding Path=GetRecentCommand,Mode=OneWay}" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" Margin="2,2,2,2" Focusable="False">
                        <Image Source="/CloudStorageLight;component/Images/page_history.png" Width="{Binding ImageWidthHeight}" Height="{Binding ImageWidthHeight}" />
                    </Button>-->
                    <Button Name="PreviousPathChangeCommand" Command="{Binding Path=PreviousPathChangeCommand,Mode=OneWay}" VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" Margin="2,2,2,2" Focusable="False">
                        <Image Source="/CloudStorageLight;component/Images/resultset_previous.png" Width="{Binding ImageWidthHeight}" Height="{Binding ImageWidthHeight}"  />
                    </Button>
                    <Button Name="ForwardPathChangeCommand" Command="{Binding Path=ForwardPathChangeCommand,Mode=OneWay}" VerticalAlignment="Center" Grid.Row="0" Grid.Column="1" Margin="2,2,2,2" Focusable="False">
                        <Image Source="/CloudStorageLight;component/Images/resultset_next.png" Width="{Binding ImageWidthHeight}" Height="{Binding ImageWidthHeight}"  />
                    </Button>
                    <TextBox Name="CurrentPath" Text="{Binding Path=CurrentPath, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True }" 
                             vg:EnterKeyBehavior.Command="{Binding Path=RefreshCommand, Mode=OneWay}" 
                             VerticalAlignment="Center" Grid.Row="0" Grid.Column="2" FontSize="{Binding Path=FontSize}"/>
                    <Button Name="RefreshCommand" Command="{Binding Path=RefreshCommand,Mode=OneWay}" VerticalAlignment="Center" Grid.Row="0" Grid.Column="3" Margin="2,2,2,2" Focusable="False">
                        <Image Source="/CloudStorageLight;component/Images/arrow_refresh.png"  Width="{Binding ImageWidthHeight}" Height="{Binding ImageWidthHeight}" />
                    </Button>
                    <TextBox Name="SearchText" Text="{Binding Path=SearchText, Mode=TwoWay, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, NotifyOnValidationError=True }" 
                             vg:EnterKeyBehavior.Command="{Binding Path=SearchCommand, Mode=OneWay}" 
                             VerticalAlignment="Center" Grid.Row="0" Grid.Column="4" FontSize="{Binding Path=FontSize}"/>
                    <Button Name="SearchCommand" Command="{Binding Path=SearchCommand,Mode=OneWay}" VerticalAlignment="Center" Grid.Row="0" Grid.Column="5" Margin="2,2,2,2" Focusable="False">
                        <Image Source="/CloudStorageLight;component/Images/find.png"  Width="{Binding ImageWidthHeight}" Height="{Binding ImageWidthHeight}" />
                    </Button>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <!--<ColumnDefinition Width="{Binding ImagePanelWith}" />-->
                        <ColumnDefinition Width="{Binding ImagePanelWith}" />
                        <ColumnDefinition Width="{Binding ImagePanelWith}" />
                        <ColumnDefinition Width="70*"/>
                        <ColumnDefinition Width="{Binding ImagePanelWith}" />
                        <ColumnDefinition Width="30*"/>
                        <ColumnDefinition Width="{Binding ImagePanelWith}" />
                    </Grid.ColumnDefinitions>
                </Grid>
                
                
                
                <TreeView Name="Folders" AllowDrop="True"
                          ItemsSource="{Binding Path=Folders,Mode=OneWay}" 
                          vg:TreeViewSelectedItemChangedBehavior.Command="{Binding Path=SelectedItemChangedCommand, Mode=OneWay}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="0" xmlns:vg="clr-namespace:ViewMaker.Core.Wpf;assembly=ViewMaker.Core">
                    <TreeView.Resources>
                        <ContextMenu x:Key="treeViewItemMenu" Visibility="{Binding Path=Data.SelectedFolder.HasContextMenu, Source={StaticResource proxy}, Converter={StaticResource BooleanToVisibilityConverter}}" >
                            <MenuItem Header="{x:Static properties:Resources.MsgRefresh}" Command="{Binding Path=Data.RefreshCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgOpenWebSite}" Command="{Binding Path=Data.OpenWebSiteCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgAddFavorite}" Visibility="{Binding Path=Data.SelectedFolder.IsNotFavoriteItem, Source={StaticResource proxy}, Converter={StaticResource BooleanToVisibilityConverter}}" Command="{Binding Path=Data.AddFavoriteCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgRemoveFavorite}" Visibility="{Binding Path=Data.SelectedFolder.IsFavoriteItem, Source={StaticResource proxy}, Converter={StaticResource BooleanToVisibilityConverter}}" Command="{Binding Path=Data.RemoveFavoriteCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <Separator/>
                            <MenuItem Header="{x:Static properties:Resources.MsgDownload}" Command="{Binding Path=Data.DownloadFolderCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgUpload}" Command="{Binding Path=Data.UploadFolderCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <Separator/>
                            <MenuItem Header="{x:Static properties:Resources.MsgCreateFolder}" Command="{Binding Path=Data.CreateFolderCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}"/>
                            <MenuItem Header="{x:Static properties:Resources.MsgRename}" Click="TreeViewItemRename_Click" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgDelete}" Visibility="{Binding Path=Data.SelectedFolder.IsNotFavoriteItem, Source={StaticResource proxy}, Converter={StaticResource BooleanToVisibilityConverter}}" Command="{Binding Path=Data.FolderDeleteCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <Separator/>
                            <MenuItem Header="{x:Static properties:Resources.MsgCopy}" Command="{Binding Path=Data.FolderCopyCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgCut}" Command="{Binding Path=Data.FolderCutCommand, Source={StaticResource proxy}}"  IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgPaste}" Command="{Binding Path=Data.FolderPasteCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=Data.Online}" DataContext="{StaticResource proxy}" />
                        </ContextMenu>
                    </TreeView.Resources>
                    <TreeView.ItemTemplate>
                        <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders,Mode=OneWay}">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{Binding Path=Icon,Mode=OneWay}" Width="{Binding Path=Data.ImageWidthHeight, Source={StaticResource proxy}}" Height="{Binding Path=Data.ImageWidthHeight, Source={StaticResource proxy}}" />
                                <TextBlock Text="{Binding Path=Title,Mode=OneWay}"  Visibility="{Binding Path=IsNotEditing, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <TextBox Text="{Binding Path=Title,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding Path=IsEditing, Converter={StaticResource BooleanToVisibilityConverter}}" KeyDown="FolderTextBox_KeyDown" LostFocus="FolderTextBox_LostFocus" IsVisibleChanged="FolderTextBox_IsVisibleChanged"  />
                            </StackPanel>
                        </HierarchicalDataTemplate>
                    </TreeView.ItemTemplate>
                    <TreeView.ItemContainerStyle>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                            <Setter Property="ContextMenu" Value="{StaticResource treeViewItemMenu}" />
                            <EventSetter Event="TreeViewItem.MouseRightButtonDown" Handler="TreeViewItem_MouseRightButtonDown"/>
                        </Style>
                    </TreeView.ItemContainerStyle>
                </TreeView>
                <GridSplitter Grid.Row="1" Grid.Column="1"  VerticalAlignment="Stretch" HorizontalAlignment="Center" Width="8" Cursor="ScrollWE">
                    <GridSplitter.Template>
                        <ControlTemplate TargetType="{x:Type GridSplitter}">
                            <Grid>
                                <Button Content="⁞" />
                                <Rectangle Fill="#00FFFFFF" />
                            </Grid>
                        </ControlTemplate>
                    </GridSplitter.Template>
                </GridSplitter>

                <Grid Name="FilesCont" Grid.Row="1" Grid.Column="2" >
                    <Grid.Resources>
                        <ContextMenu x:Key="listViewItemMenu" >
                            <MenuItem Header="{x:Static properties:Resources.MsgOpen}" Command="{Binding Path=Data.FilesOpenCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanOpen}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgCheckout}" Command="{Binding Path=Data.CheckoutExecuteFileCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanCheckout}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgUpload}" Command="{Binding Path=Data.UploadFileCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanUpload}"  />
                            <MenuItem Header="{x:Static properties:Resources.MsgCheckin}" Command="{Binding Path=Data.CheckinCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanCheckin}"  />
                            <MenuItem Header="{x:Static properties:Resources.MsgCancelCheckout}" Command="{Binding Path=Data.CancelCheckoutCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanCheckin}"  />
                            <!--<MenuItem Header="{x:Static properties:Resources.MsgReload}" Command="{Binding Path=Data.ReloadExecuteFileCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanReload}" />-->
                            <Separator/>
                            <!--<MenuItem Header="{x:Static properties:Resources.MsgHistory}" Command="{Binding Path=Data.ShowHistoryItemCommand, Source={StaticResource proxy}}"  IsEnabled="{Binding Path=SelectedFile.CanShowHistory}"  />-->
                            <!--<MenuItem Header="{x:Static properties:Resources.MsgShowUrl}" Command="{Binding Path=Data.ShowUrlCommand, Source={StaticResource proxy}}"  IsEnabled="{Binding Path=SelectedFile.CanShowUrl}"  />-->
                            <MenuItem Header="{x:Static properties:Resources.MsgCopyUrlToClipBoard}" Command="{Binding Path=Data.CopyUrlToClipboardCommand, Source={StaticResource proxy}}"  IsEnabled="{Binding Path=SelectedFile.CanShowUrl}"  />
                            <MenuItem Header="{x:Static properties:Resources.MsgCopy}" Command="{Binding Path=Data.FilesCopyCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanCopy}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgCut}" Command="{Binding Path=Data.FilesCutCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=CanCut}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgPaste}" Command="{Binding Path=Data.FilesPasteCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanPaste}" />
                            <Separator/>
                            <!--<MenuItem Header="{x:Static properties:Resources.MsgSave}" Command="{Binding Path=Data.FilesSaveCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanSave}" />-->
                            <!--<MenuItem Header="{x:Static properties:Resources.MsgDownload}" Command="{Binding Path=Data.ReloadCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanDownload}" />-->
                            <!--<MenuItem Header="{x:Static properties:Resources.MsgUpload}" Command="{Binding Path=Data.UploadFileCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanUpload}"  />-->
                            <Separator/>
                            <MenuItem Header="{x:Static properties:Resources.MsgRename}" Click="ListViewItemRename_Click" IsEnabled="{Binding Path=SelectedFile.CanRename}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgDelete}" Command="{Binding Path=Data.FilesDeleteCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanDelete}" />
                            <MenuItem Header="{x:Static properties:Resources.MsgDeleteCompletely}" Command="{Binding Path=Data.FilesDeleteCompletelyCommand, Source={StaticResource proxy}}" IsEnabled="{Binding Path=SelectedFile.CanDeleteCompletely}" />
                        </ContextMenu>
                    </Grid.Resources>
                    <local:AppListView x:Name="Files" AllowDrop="True" SelectionMode="Extended" 
                          SelectedItem="{Binding Path=SelectedFile}"
                          ItemsSource="{Binding Path=Files,Mode=OneWay}" 
                          VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 
                          MouseDoubleClick="ListView_MouseDoubleClick" 
                          ContextMenu="{StaticResource listViewItemMenu}"
                          GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
                          xmlns:vg="clr-namespace:ViewMaker.Core.Wpf;assembly=ViewMaker.Core">
                        <local:AppListView.CommandBindings>
                        </local:AppListView.CommandBindings>
                        <local:AppListView.InputBindings>
                            <KeyBinding Key="DELETE" Command="{Binding FilesDeleteCommand}" />
                            <KeyBinding Key="DELETE" Modifiers="Shift" Command="{Binding FilesDeleteCompletelyCommand}" />
                            <KeyBinding Key="C" Modifiers="Control" Command="{Binding FilesCopyCommand}"></KeyBinding>
                            <!--<KeyBinding Key="X" Modifiers="Control" Command="{Binding FilesCutCommand}"></KeyBinding>-->
                            <KeyBinding Key="V" Modifiers="Control" Command="{Binding FilesPasteCommand}"></KeyBinding>
                            <KeyBinding Key="S" Modifiers="Control" Command="{Binding FilesSaveCommand}"></KeyBinding>
                        </local:AppListView.InputBindings>
                        <local:AppListView.Background>

                            <ImageBrush ImageSource="/CloudStorageLight;component/Images/cloudstoragelightlogo.png" Opacity="0.05" Stretch="UniformToFill "/>
                        </local:AppListView.Background>
                        <local:AppListView.View>
                            <GridView>
                                <GridViewColumn Header="{x:Static properties:Resources.MsgTitle}" Width="{Binding FileNameWidth, Mode=TwoWay}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal" >
                                                <CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center"></CheckBox>
                                                <Image Source="{Binding Path=ExeIcon,Mode=OneWay}" Width="{Binding Path=Data.ImageWidthHeight, Source={StaticResource proxy}}" Height="{Binding Path=Data.ImageWidthHeight, Source={StaticResource proxy}}" Margin="10,0,10,0">                                            
                                                </Image>
                                                <TextBlock Text="{Binding Path=Title,Mode=OneWay}" ToolTip="{Binding Path=Path}"  Visibility="{Binding Path=IsNotEditing, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                                <TextBox Text="{Binding Path=Title,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding Path=IsEditing, Converter={StaticResource BooleanToVisibilityConverter}}" KeyDown="FileTextBox_KeyDown" LostFocus="FileTextBox_LostFocus" IsVisibleChanged="FileTextBox_IsVisibleChanged"  />
                                                <Image Source="{Binding Path=OptionIcon,Mode=OneWay}" Height="15" Margin="10,0,10,0"  Visibility="{Binding Path=IsLocalEditing, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                                <TextBlock Margin="10,0,0,0" Text="{Binding Path=CheckoutUser, Mode=OneWay}" Foreground="Blue"/>
                                                <TextBlock Margin="10,0,0,0" Text="{Binding Path=Message, Mode=OneWay}" Foreground="Red"/>
                                                <TextBlock Margin="10,0,0,0" Text="{Binding Path=Remark, Mode=OneWay}" Foreground="Red"/>
                                                <StackPanel.Style>
                                                    <Style TargetType="StackPanel">
                                                        <Style.Triggers>
                                                            <!--<DataTrigger Binding="{Binding Downloading}" Value="True">
                                                                <DataTrigger.EnterActions>
                                                                    <BeginStoryboard>
                                                                        <Storyboard>
                                                                            <DoubleAnimation
                                                                                 Storyboard.TargetProperty="Opacity"
                                                                                 From="0.25" To="0.5" Duration="0:0:1" 
                                                                                 RepeatBehavior="Forever"
                                                                                 AutoReverse="True"/>
                                                                        </Storyboard>
                                                                    </BeginStoryboard>
                                                                </DataTrigger.EnterActions>
                                                                <DataTrigger.ExitActions>
                                                                    <BeginStoryboard>
                                                                        <Storyboard FillBehavior="Stop">
                                                                            <DoubleAnimation
                                                                                  Storyboard.TargetProperty="Opacity"
                                                                                  To="1" Duration="0:0:1" />
                                                                        </Storyboard>
                                                                    </BeginStoryboard>
                                                                </DataTrigger.ExitActions>
                                                            </DataTrigger>-->
                                                        </Style.Triggers>
                                                    </Style>
                                                </StackPanel.Style>
                                            </StackPanel>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="{x:Static properties:Resources.MsgSize}" Width="{Binding SizeWidth, Mode=TwoWay}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock HorizontalAlignment="Right" Text="{Binding Path=SizeString}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="{x:Static properties:Resources.MsgLastModified}"  Width="{Binding ModifiedDateWidth, Mode=TwoWay}" >
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=LocalLastModified}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="{x:Static properties:Resources.MsgLastModifiedBy}" Width="{Binding ModifiedByWidth, Mode=TwoWay}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=Owner}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </local:AppListView.View>
                        <local:AppListView.ItemContainerStyle>
                            <Style TargetType="{x:Type ListViewItem}">
                                <EventSetter Event="PreviewMouseLeftButtonDown" Handler="OnListViewItem_PreviewMouseLeftButtonDown" />
                                <!--<Setter Property="ContextMenu" Value="{StaticResource listViewItemMenu}"/>-->
                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                            </Style>
                        </local:AppListView.ItemContainerStyle>
                    </local:AppListView>
                    <!--<GridSplitter Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Height="5" Cursor="ScrollNS">
                    </GridSplitter>-->

                    <Grid Name="PreviewCont" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="{Binding Path=SelectedFile.HasSearchContent, Converter={StaticResource BooleanToVisibilityConverter}}" MaxHeight="{Binding SearchPanelMaxHeight}" >
                        <ScrollViewer>
                            <TextBlock Text="{Binding Path=SelectedFile.SearchContent}" TextWrapping="Wrap" />
                        </ScrollViewer>
                    </Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                        <!--<RowDefinition Height="auto" />-->
                    </Grid.RowDefinitions>
                </Grid>

                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="3*"/>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="7*"/>
                </Grid.ColumnDefinitions>
            </Grid>
        </ContentControl>
        <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding Path=IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Row="1" >
            <Border Padding="15,15,15,15" Background="LightGray" Opacity="1">
                <StackPanel 
                    Width="{Binding 
                       Converter={StaticResource PercentageConverter}, 
                       ElementName=MainVM, 
                       Path=ActualWidth, 
                       ConverterParameter=0.7}"
                    Height="240" MinWidth="300" >
                    <StackPanel Margin="10">
                        <local:LoadingWait></local:LoadingWait>
                    </StackPanel>
                    <ScrollViewer Height="150" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                        <TextBlock Name="progressMessage" TextWrapping="Wrap" HorizontalAlignment="Center" Text="{Binding Path=ProgressMessage}">
                        </TextBlock>
                    </ScrollViewer>
                    <Button Name="Cancel" ForceCursor="false" Cursor="Hand" HorizontalAlignment="Center" Command="{Binding Path=CancelCommand}" Visibility="{Binding Path=CanCancel, Converter={StaticResource BooleanToVisibilityConverter}}" >
                        <TextBlock Text="{x:Static properties:Resources.MsgCancel}" />
                    </Button>
                </StackPanel>
            </Border>
        </StackPanel>

        <StatusBar Grid.Row="2">
            <StatusBarItem DockPanel.Dock="Left">
                <TextBlock FontSize="12px" Text="{Binding Path=Message}" ></TextBlock>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
